/**
 * 企业用户管理
 */
/**
 * 企业用户管理数据源
 */
user_enterprise_manage_girdpanel_store = new Ext.data.Store({
			proxy : new Ext.data.HttpProxy({
						method : 'GET',
						url : 'qyyhgl/getenterpriseuser.action?city_id='
								+ user_city
					}),
			reader : new Ext.data.JsonReader({
						fields : ['id', 'name', 'user_id', 'editable',
								'enterprise_state', 'enterprise_style',
								'enterprise_expe_year', 'enterprise_demo_year',
								'enterprise_is_nationalInnovation',
								'enterprise_updateinfo',
								'enterprise_updatestatus', 'enterprise_name',
								'enterprise_address',
								'enterprise_corporate_code', 'enterprise_city',
								'enterprise_postcode',
								'enterprise_corporateRepresentative',
								'enterprise_telephone',
								'enterprise_person_incharge',
								'enterprise_phone_incharge',
								'enterprise_eco_type', 'enterprise_org_type',
								'enterprise_largest_sharehoder',
								'enterprise_largest_share',
								'enterprise_listed_type',
								'enterprise_science_type',
								'enterprise_industry_code',
								'enterprise_highsci_authenticate_year',
								'enterprise_highsci_authenticate_department',
								'enterprise_highsci_field',
								'enterprise_credit_degree',
								'enterprise_business_field',
								'enterprise_field_closeness',
								'enterprise_major_business',
								'enterprise_staff_count',
								'enterprise_staff_collegedegree_count',
								'enterprise_research_staff_count',
								'enterprise_senior_technician_count', 'isCheck']
					}),
			autoLoad : true
		});
user_enterprise_manage_girdpanel = Ext.extend(Ext.grid.GridPanel, {
	store : null,
	constructor : function() {
		this.store = user_enterprise_manage_girdpanel_store;
		user_enterprise_manage_girdpanel.superclass.constructor.call(this, {
			loadMask : {
				msg : '数据加载中...'
			},
			title : '企业用户列表',
			iconCls : 'chimouser',
			tbar : [{
						text : '重置密码',
						iconCls : 'smlmanage',
						handler : this.resetPwd,
						scope : this
					}, '-', {
						text : '删除',
						iconCls : 'deletepart',
						handler : this.deleteUse,
						scope : this
					}, '-', {
						text : '企业详细信息列表',
						iconCls : 'detaillook',
						handler : function() {
							var ro = this.getSelectionModel().getSelected();
							if (!ro) {
								Ext.Msg.show({
											title : '提示',
											msg : '没有选择相应数据',
											icon : Ext.Msg.ERROR,
											buttons : Ext.MessageBox.OK
										});
								return;
							} else {
								var enterprise_name = ro.get('enterprise_name');
								var enterprise_city = ro.get('enterprise_city');
								var enterprise_address = ro
										.get('enterprise_address');
								var enterprise_post_code = ro
										.get('enterprise_postcode');
								var enterprise_corporate_code = ro
										.get('enterprise_corporate_code');
								var enterprise_corporateRepresentative = ro
										.get('enterprise_corporateRepresentative');
								var enterprise_telephone = ro
										.get('enterprise_telephone');
								var enterprise_person_incharge = ro
										.get('enterprise_person_incharge');
								var enterprise_phone_incharge = ro
										.get('enterprise_phone_incharge');
								var enterprise_eco_type = ro
										.get('enterprise_eco_type');
								var enterprise_org_type = ro
										.get('enterprise_org_type');
								var enterprise_largest_sharehoder = ro
										.get('enterprise_largest_sharehoder');
								var enterprise_largest_share = ro
										.get('enterprise_largest_share');
								var enterprise_listed_type = ro
										.get('enterprise_listed_type');
								var enterprise_science_type = ro
										.get('enterprise_science_type');
								var enterprise_industry_code = ro
										.get('enterprise_industry_code');
								var enterprise_credit_degree = ro
										.get('enterprise_credit_degree');
								var enterprise_field_closeness = ro
										.get('enterprise_field_closeness');
								var enterprise_business_field = ro
										.get('enterprise_business_field');
								var enterprise_major_business = ro
										.get('enterprise_major_business');
								var enterprise_staff_count = ro
										.get('enterprise_staff_count');
								var enterprise_staff_collegedegree_count = ro
										.get('enterprise_staff_collegedegree_count');
								var enterprise_research_staff_count = ro
										.get('enterprise_research_staff_count');
								var enterprise_senior_technician_count = ro
										.get('enterprise_senior_technician_count');
								var cfg = {
									enterprise_name : enterprise_name,
									enterprise_city : enterprise_city,
									enterprise_address : enterprise_address,
									enterprise_post_code : enterprise_post_code,
									enterprise_corporate_code : enterprise_corporate_code,
									enterprise_corporateRepresentative : enterprise_corporateRepresentative,
									enterprise_telephone : enterprise_telephone,
									enterprise_person_incharge : enterprise_person_incharge,
									enterprise_phone_incharge : enterprise_phone_incharge,
									enterprise_eco_type : enterprise_eco_type,
									enterprise_org_type : enterprise_org_type,
									enterprise_largest_sharehoder : enterprise_largest_sharehoder,
									enterprise_largest_share : enterprise_largest_share,
									enterprise_listed_type : enterprise_listed_type,
									enterprise_science_type : enterprise_science_type,
									enterprise_industry_code : enterprise_industry_code,
									enterprise_credit_degree : enterprise_credit_degree,
									enterprise_field_closeness : enterprise_field_closeness,
									enterprise_business_field : enterprise_business_field,
									enterprise_major_business : enterprise_major_business,
									enterprise_staff_count : enterprise_staff_count,
									enterprise_staff_collegedegree_count : enterprise_staff_collegedegree_count,
									enterprise_research_staff_count : enterprise_research_staff_count,
									enterprise_senior_technician_count : enterprise_senior_technician_count
								};
								var win = new enterprise_show_win(cfg);
								win.show(Ext.getDom('login_view'));
							}
						},
						scope : this

					}],
			columns : [new Ext.grid.RowNumberer(), {
						id : 'enterprise_id',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'id'
					}, {
						id : 'user_id',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'user_id'
					}, {
						id : 'editable',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'editable'
					}, {
						id : 'enterprise_post_code',
						header : '企业邮编',
						width : 80,
						hidden : false,
						sortable : true,
						dataIndex : 'enterprise_postcode'
					}, {
						id : 'enterprise_corporate_code',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_corporate_code'
					}, {
						id : 'enterprise_telephone',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_telephone'
					}, {
						id : 'enterprise_largest_sharehoder',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_largest_sharehoder'
					}, {
						id : 'enterprise_largest_share',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_largest_share'
					}, {
						id : 'enterprise_listed_type',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_listed_type'
					}, {
						id : 'enterprise_science_type',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_science_type'
					}, {
						id : 'enterprise_credit_degree',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_credit_degree'
					}, {
						id : 'enterprise_field_closeness',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_field_closeness'
					}, {
						id : 'enterprise_business_field',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_business_field'
					}, {
						id : 'enterprise_major_business',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_major_business'
					}, {
						id : 'enterprise_staff_count',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_staff_count'
					}, {
						id : 'enterprise_major_business',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_major_business'
					}, {
						id : 'enterprise_staff_collegedegree_count',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_staff_collegedegree_count'
					}, {
						id : 'enterprise_research_staff_count',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_research_staff_count'
					}, {
						id : 'enterprise_senior_technician_count',
						header : '',
						width : 80,
						hidden : true,
						sortable : true,
						dataIndex : 'enterprise_senior_technician_count'
					}, {
						header : '所属市',
						width : 60,
						dataIndex : 'enterprise_city',
						sortable : true,
						renderer : getCityName,
						align : 'center'
					}, {// /////////////////////////////////////////////////////////////////////
						header : '企业名称',
						width : 60,
						dataIndex : 'enterprise_name',
						id : 'enterprise_name',
						sortable : true,
						align : 'center'
					}, {// /////////////////////////////////////////////////////////////
						id : 'enterprise_address',
						header : '公司地址',
						width : 100,
						// hidden : true,
						sortable : true,
						dataIndex : 'enterprise_address'
					}, {
						id : 'enterprise_corporateRepresentative',
						header : '企业法人代表',
						width : 80,
						// hidden : true,
						sortable : true,
						dataIndex : 'enterprise_corporateRepresentative'
					}, {
						id : 'name',
						header : '登录账号',
						width : 80,
						// hidden : true,
						sortable : true,
						dataIndex : 'name'
					}, {
						header : '试点工作负责人',
						width : 60,
						dataIndex : 'enterprise_person_incharge',
						sortable : true,
						align : 'center'
					}, {
						header : '负责人电话',
						width : 60,
						dataIndex : 'enterprise_phone_incharge',
						sortable : true,
						align : 'center'
					}, {
						header : '经济类型',
						width : 60,
						hidden : true,
						dataIndex : 'enterprise_eco_type',
						sortable : true,
						renderer : getEnterprise_eco_typeName,
						align : 'center'
					}, {
						header : '组织类型',
						width : 60,
						hidden : true,
						dataIndex : 'enterprise_org_type',
						sortable : true,
						renderer : getEnterprise_org_typeName,
						align : 'center'
					}, {
						header : '科技型企业类别',
						width : 60,
						hidden : true,
						dataIndex : 'enterprise_science_type',
						sortable : true,
						renderer : getEnterprise_science_typeName,
						align : 'center'
					}, {
						header : '所属国民经济行业',
						width : 60,
						hidden : true,
						dataIndex : 'enterprise_industry_code',
						sortable : true,
						renderer : getProfessionName,
						align : 'center'
					}, {
						header : '审核状态',
						width : 60,
						hidden : true,
						dataIndex : 'isCheck',
						renderer : getIsCheckName,
						sortable : false,
						align : 'center'
					}],
			autoExpandColumn : 'enterprise_name',
			ds : this.store,

			stripeRows : true,
			split : true,
			viewConfig : {
				forceFit : true
			}
		})
	},
	resetPwd : function() {
		var ro = this.getSelectionModel().getSelected();
		if (!ro) {
			Ext.Msg.show({
						title : '提示',
						msg : '没有选择相应删除数据',
						icon : Ext.Msg.ERROR,
						buttons : Ext.MessageBox.OK
					});
			return;
		} else {
			var userid = ro.get('user_id');
			Ext.Ajax.request({
						url : 'qyyhgl/updateuserpwd.action',
						success : function(response, options) {
							Ext.Msg.alert('提示','&nbsp&nbsp&nbsp&nbsp&nbsp密码更改成功&nbsp&nbsp&nbsp&nbsp');
						},
						params : {
							userId : userid
						},
						scope : this
					});
		}
	},
	deleteUse : function() {
		var ro = this.getSelectionModel().getSelected();
		if (!ro) {
			Ext.Msg.show({
						title : '提示',
						msg : '没有选择相应删除数据',
						icon : Ext.Msg.ERROR,
						buttons : Ext.MessageBox.OK
					});
			return;
		} else {
			var name = ro.get('enterprise_name');
			var userid = ro.get('user_id');
			Ext.Msg.confirm('确定', '你确定要删除<font color="red">' + name
							+ '</font>?', function(btn) {
						if (btn == 'yes') {
							Ext.Ajax.request({
										url : 'qyyhgl/deleteuser.action',
										success : function(response, options) {
											if (response.responseText == 'ok') {
												Ext.Msg.alert('提示',
														'成功删除<font color="red">'
																+ name
																+ '</font>');
												this.getStore().reload();
											}
										},
										params : {
											userId : userid
										},
										scope : this
									});
						}
					}, this);
		}
	}
});
Ext.extend(demo.module, {
			init : function() {
				this.body = new user_enterprise_manage_girdpanel();
				this.main.add(this.body);
				this.main.doLayout();
			}
		});